package com.wude.guild.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wude.bean.MyCouponBean;
import com.wude.guild.holder.CouponAlreadyHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述：我的优惠券-已使用
 * 作者：闫冰
 * 时间: 2017-09-05 16:17
 */
public class MyCouponAlreadyAdapter extends BaseAdapter {
    private Activity activity;
    private List<MyCouponBean.DataBean.UseBean> list = new ArrayList<>();

    public MyCouponAlreadyAdapter(Activity activity) {
        this.activity = activity;
    }

    public List<MyCouponBean.DataBean.UseBean> getList() {
        return list;
    }

    public void setList(List<MyCouponBean.DataBean.UseBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CouponAlreadyHolder holder = null;
        if (convertView == null){
            holder = new CouponAlreadyHolder();
        }else {
            holder = (CouponAlreadyHolder) convertView.getTag();
        }
        holder.setData(list.get(position),position,activity);
        return holder.getContentView();
    }
}
